<?php
$pdo = new PDO("mysql:host=localhost;dbname=hospital","root","tailiyan88");

$json_string = file_get_contents("a.json");

$obj=json_decode($json_string,true);

foreach($obj as $v)
{

    $key=$v['key'];
    $province=$v['label'];
    $pdo->exec("insert into province(`p`,`code`) values('$province','$key')");
    if(!empty($v["children"])&& is_array($v["children"]))
    {

        foreach($v["children"] as $c)
        {
            echo "insert into city(`c`,`code`,`pno`) values('".$c['label']."','".$c['key']."','".$v['key']."')";
            $pdo->exec("insert into city(`c`,`code`,`pno`) values('".$c['label']."','".$c['key']."','".$v['key']."')");
            if(!empty($c["children"])&& is_array($c["children"]))
            {
                foreach($c["children"] as $s)
                {
                    $pdo->exec("insert into area(`a`,`code`,`pno`) values('".$s['label']."','".$s['key']."','".$c['key']."')");
                }
            }

        }
    }

}
